package com.example.factory.api.constant;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Lei Tao
 */
public abstract class ErrorCode {
    public static final Map<Integer, String> ERRORS = new HashMap<>();
    static {
        // 1000-1999 通用
        ERRORS.put(1000, "非法操作");
        ERRORS.put(1001, "参数不合法");


        //2001-2999 部门
        ERRORS.put(2001, "部门不存在");

        //3001-3999 设备
        ERRORS.put(3001, "部门不存在");
    }
    public static String put(Integer code, String msg) {
        return ERRORS.put(code, msg);
    }

    public static String msg(int status) {
        String msg = ERRORS.get(status);
        if (StringUtils.isEmpty(msg)) {
            msg = "Error[" + status + "] undefined";
        }
        return msg;
    }
}
